package com.psp.dao.impl;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.psp.base.BaseDaoImpl;
import com.psp.dao.ForumDao;
import com.psp.dao.OptionDao;
import com.psp.dao.RespondDao;
import com.psp.domain.Forum;
import com.psp.domain.Option;
import com.psp.domain.Questionnaire;
import com.psp.domain.Respond;

@Repository
@SuppressWarnings("unchecked")
public class RespondDaoImpl extends BaseDaoImpl<Respond> implements RespondDao{

	@Override
	public Long ipAddress2QuestionnaireCount(Questionnaire questionnaire,
			String ipAddress) {
		return (Long) getSession().createQuery(//
				"SELECT COUNT(*) FROM Respond r WHERE r.questionnaire=? AND r.ipAddress =?")
				.setParameter(0, questionnaire)//
				.setParameter(1, ipAddress)//
				.uniqueResult();
	}
}
